const mongoose = require('mongoose')

const messageSchema = new mongoose.Schema({
  type: {
    type: String,
    required: true
  },
  ref: {
    type: mongoose.Schema.ObjectId,
    ref: 'Registration',
    required: false
  },
  read: {
    type: Boolean,
    required: true,
    default: () => false
  },
  sendor: {
    type: mongoose.Schema.ObjectId,
    ref: 'User',
    required: false
  },
  deleted: {
    type: Boolean,
    required: true,
    default: () => false
  },
  note: {
    type: String,
    required: false
  }
})

const messageModel = mongoose.model('Message', messageSchema)

module.exports = messageModel